home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / gus / ail_hold.zip / PUTAIL.C next >
C/C++ Source or Header  |  1993-08-14  |  2KB  |  68 lines

  1. /*  Sound improver for StrongHold(tm) by Royce Liao
  2.     Source code for PUTAIL.EXE
  3.     This program will install the Gravis MIDI driver into the stronghold
  4.     data file, and thus improve it.  Whether or not you hear BETTER
  5.     music is a different issue... :)
  6.     Of course, this program could alter games beside StrongHold(tm)
  7.     -- I assume no responsibility for damages, headaches, stress, etc.
  8.         etc.etc, caused by the use of this program.  I.E., if this
  9.         doesn't work, don't blame me!    */
  10.  
  11. #define BUFFER_SIZE        1024
  12. #define ROLAND_OFFSET    0x3289C5L
  13. #define STRING_LENGTH    40
  14.  
  15. #include<stdio.h>
  16. #include<conio.h>
  17. void main()
  18. {
  19.     unsigned long offset, counter, total;
  20.     unsigned char buffer[BUFFER_SIZE];
  21.     unsigned char out_name[STRING_LENGTH], adv_name[STRING_LENGTH];
  22.     int lcv;
  23.  
  24.     FILE *file_out, *file_adv;
  25.         /*    file_out is the file to be altered (patched)
  26.             file_adv is the file to be inserted (into file_out)    */
  27.  
  28.     counter=0;
  29.     printf("\nEnter name of file to alter: ");
  30.     scanf("%s", out_name ) ;
  31.     file_out= fopen ( out_name, "rb+");
  32.     if ( file_out==NULL )  {
  33.         fprintf( stderr," Could not open  %s", out_name );
  34.         exit(1);
  35.         }
  36.  
  37.     printf("\nEnter name of file to install. (.ADV file) ");
  38.     printf("\n");
  39.     scanf("%s", adv_name ) ;
  40.     file_adv= fopen ( adv_name, "rb");
  41.     if ( file_adv==NULL )    {
  42.         fprintf( stderr, "Could not open  %s", adv_name );
  43.         fclose ( file_out ) ;
  44.         exit(1);
  45.         }
  46.  
  47.     printf("\n(For the game StrongHold(tm), I think the offset for",
  48.           "the Roland driver is %ld decimal.", ROLAND_OFFSET );
  49.     printf("\nInsert %s at what offset (decimal from beginning) ? ",
  50.         adv_name );
  51.     scanf("%lu", &offset);
  52.  
  53.     total=0;
  54.     fseek(file_out, offset, SEEK_SET);
  55.     fseek(file_adv, 0, SEEK_SET);
  56.     do    {
  57.         counter= fread(buffer, sizeof(char), BUFFER_SIZE, file_adv);
  58.         fwrite(buffer, sizeof(char), counter, file_out);
  59.         total+=counter;
  60.         }
  61.     while ( counter==BUFFER_SIZE ) ;
  62.  
  63.     printf("\nTotal bytes (re)written into %s = %lu", out_name, total);
  64.     fclose( file_out );
  65.     fclose( file_adv );
  66. }
  67.  
  68. /*  Compiled with Borland Turbo C++ 3.0 (DOS)...Tiny memory model, 8088 code.*/